<template>
    <div>
        <Home-header :city='city'></Home-header>
        <Home-swiper :list='swiper'></Home-swiper>
        <Home-icons :list='iconList'></Home-icons>
        <Home-recommend :list='recommendList'></Home-recommend>
        <Home-weekend :list='weekendList'></Home-weekend>
    </div>
</template>
<script>
import HomeHeader from './component/Header'
import HomeSwiper from './component/Swiper'
import HomeIcons from './component/Icons'
import HomeRecommend from './component/Recommend'
import HomeWeekend from './component/Weekend'
import axios from 'axios'
export default {
  name: 'home',
  components: {
    HomeHeader,
    HomeSwiper,
    HomeIcons,
    HomeRecommend,
    HomeWeekend
  },
  mounted () {
    this.getData()
  },
  data () {
    return {
      city: '',
      iconList: [],
      recommendList: [],
      swiper: [],
      weekendList: []
    }
  },
  methods: {
    getData () {
      axios.get('/api/index.json').then(this.getDataSucc)
    },
    getDataSucc (res) {
      res = res.data
      var data = res.data
      console.log(res, data)
      if ((res.ret === true) && data) {
        this.city = data.city
        this.iconList = data.iconList
        this.recommendList = data.recommendList
        this.swiper = data.swiperList
        console.log(this.swiper)
        this.weekendList = data.weekendList
      }
    }
  }
}
</script>
<style scoped>
</style>
